HAL CCB migration: List of applicable concepts

This section provides information about the HAL CCB applicable architecture concepts.

Concepts for CCB

Concept

Description

Separation of initialization and configuration functions

In HAL2,The HAL_CCB_Init() link the logical object (handle) to the physical peripheral instance.

The CCB does not require global configuration, so there is no HAL_CCB_SetConfig() function.

The various CCB operations are still available through dedicated functions same as HAL1.

Renaming of the handle structure

The handle structure has been renamed to hal_ccb_handle_t.

Remove MspInit and MspDeInit callbacks

The functions hal_ccb_MspInit() and hal_ccb_MspDeInit() are removed and replaced by a user-defined sequence for CCB initialization.

Introduction of HAL user data set/get APIs

Two functions to set and get user data are available: HAL_CCB_SetUserData and HAL_CCB_GetUserData.

Revised and optimized HAL state machine

The CCB state machine has been reworked to ensure transitions of the peripheral functional states.

Revised and optimized HAL API status returns

The HAL CCB functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

The error management function has been renamed to HAL_CCB_GetLastErrorCodes().

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL CCB driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros are used to check the parameters and state of the HAL CCB driver.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Convert finite parameters, including CCB instances, into enumerated types (enums) at the HAL level to enhance code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL CCB functions start with HAL_CCB. All HAL CCB enumerations and structures start with hal_ccb.